﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RabbitBus
{
    /// <summary>
    /// 消费者基类
    /// </summary>
    /// <typeparam name="TEvent"></typeparam>
    public abstract class ConsumerBase<TEvent> : IEventConsumer<TEvent> where TEvent : BusEvent
    {

        /// <summary>
        /// 基类消费方法
        /// </summary>
        /// <param name="eEvent"></param>
        public void Consume(TEvent eEvent)
        {
            try
            {
                Receive(eEvent);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 消费者接收处理消息
        /// </summary>
        /// <param name="eEvent">消息体</param>
        protected abstract void Receive(TEvent eEvent);
    }
}
